package office.word.poi;

import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Iterator;

public class WordTest {

    public static void main(String[] args) throws IOException {

        String templatePath = "D:\\codespace\\alldemo\\java-test-project\\templates\\测试.doc";




        XWPFDocument document = new XWPFDocument(new FileInputStream(templatePath));
        // 循环段落替换变量
        Iterator<XWPFParagraph> paragraphsIterator = document.getParagraphsIterator();
        while (paragraphsIterator.hasNext()) {
            XWPFParagraph next = paragraphsIterator.next();
            System.out.println(next.getText());
        }
    }

}
